function isObject(value) {
  const valueType = typeof value;
  return (value !== null) && (valueType === "object" || valueType === "function");
}

function deepClone(originValue) {
  // 判断传入的东西是否为对象类型
  if(!isObject(originValue)) {
    return originValue;
  }
  const newObject = {};
  for (const key in originValue) {
    newObject[key] = deepClone(originValue[key]);
  }
  return newObject;
}

const obj = {
  name: "yz",
  age: 18,
  friend: {
    name: "james",
    address: {
      city: "北京",
    }
  }
}

const newObj = deepClone(obj);
console.log(newObj === obj);

obj.friend.name = "jaja";
console.log("obj")
console.log(obj)
console.log("newObj");
console.log(newObj);

